package com.lee.rpc.protocal.serial;

import java.util.concurrent.ConcurrentHashMap;

public class SerializerManager {

	private final static ConcurrentHashMap<Byte, ISerializer> serializerMap = new ConcurrentHashMap<>();

	static {
		JavaSerializer java = new JavaSerializer();
		JsonSerializer json = new JsonSerializer();
		serializerMap.put(java.getType(), java);
		serializerMap.put(json.getType(), json);
	}

	public static ISerializer getSerializer(byte key) {
		ISerializer iSerializer = serializerMap.get(key);
		if (iSerializer == null) {
			return new JavaSerializer();
		}
		return iSerializer;
	}
}
